<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="../../include/tag.jsp"%>
<html>
<head>
    <title>主页</title>
    <link rel="stylesheet" href="${ctx}/css/common/list.css">
    <link rel="stylesheet" href="${ctx}/css/common/table.css">
    <link rel="stylesheet" href="${ctx}/css/ui/system/member/member_list.css">
    <link rel="stylesheet" href="${ctx}/css/ui/system/main/main.css">
    <%@include file="../../include/commonFile.jsp"%>
</head>
<body>
<%@include file="../../include/header.jsp"%>
    <div class="index-outside">
        <%@include file="../../include/sidebar.jsp"%>
        <c:if test="${!permissions.noPermission}">
            <section>
                <div class="head-main-car">
                        <%--<div class="info-box bg-light-blue">
                            <div class="box-content " id="apply-num">
                                <div class="box-icon">
                                <i class="iconfont icon-squarecheck btn-icon"></i>
                                </div>
                                <div class="box-inner">
                                    <div class="num">${onHandApply}</div>
                                    <div class="info">活动报名待审核数</div>
                                </div>
                            </div>
                        </div>--%>
                    <c:if test="${permissions.allApply}">
                        <div class="info-box bg-green">
                            <div class="box-content " id="allApply-num">
                                <div class="box-icon">
                                    <i class="iconfont icon-friendadd btn-icon"></i>
                                </div>
                                <div class="box-inner">
                                    <div class="num">${allApply}</div>
                                    <div class="info">所有报名数</div>
                                </div>
                            </div>
                        </div>
                    </c:if>
                    <c:if test="${permissions.allOrder}">
                        <div class="info-box bg-orange">
                            <div class="box-content " id="order-num">
                                <div class="box-icon">
                                    <i class="iconfont icon-form btn-icon"></i>
                                </div>
                                <div class="box-inner">
                                    <div class="num">${allOrder}</div>
                                    <div class="info">所有订单数</div>
                                </div>
                            </div>
                        </div>
                    </c:if>
                    <c:if test="${permissions.allMember}">
                        <div class="info-box bg-red">
                            <div class="box-content " id="member-num">
                                <div class="box-icon">
                                    <i class="iconfont icon-group btn-icon"></i>
                                </div>
                                <div class="box-inner">
                                    <div class="num">${allMember}</div>
                                    <div class="info">所有注册会员数</div>
                                </div>
                            </div>
                        </div>
                    </c:if>
                    <c:if test="${permissions.allMoney}">
                        <div class="info-box bg-blue">
                            <div class="box-content " >
                                <div class="box-icon">
                                    <i class="iconfont icon-moneybag btn-icon"></i>
                                </div>
                                <div class="box-inner">
                                    <div class="num"><fmt:formatNumber value="${allTotal}" pattern="0.00"/></div>
                                    <div class="info">所有资金数</div>
                                </div>
                            </div>
                        </div>
                    </c:if>
                    <c:if test="${permissions.allVisit}">
                        <div class="info-box bg-light-blue">
                            <div class="box-content " id="">
                                <div class="box-icon">
                                    <i class="iconfont icon-footprint btn-icon"></i>
                                </div>
                                <div class="box-inner">
                                    <div class="num">${map.history.viewNum}</div>
                                    <div class="info">所有访问数</div>
                                </div>
                            </div>
                        </div>
                    </c:if>
                </div>
                <div class="section-main">
                    <div>
                        <div class="list-content">
                            <div class="cl">
                                <table class="layui-table">
                                    <colgroup>
                                        <col width="100">
                                        <c:if test="${permissions.allApply}">
                                            <col width="100">
                                        </c:if>
                                        <c:if test="${permissions.allOrder}">
                                            <col width="100">
                                        </c:if>
                                        <c:if test="${permissions.allMoney}">
                                            <col width="100">
                                        </c:if>
                                        <c:if test="${permissions.allVisit}">
                                            <col width="100">
                                        </c:if>
                                        <c:if test="${permissions.allMember}">
                                            <col width="100">
                                        </c:if>
                                        <c:if test="${permissions.allRealMember}">
                                            <col width="100">
                                        </c:if>
                                    </colgroup>
                                    <thead>
                                    <tr>
                                        <th>数据</th>
                                        <c:if test="${permissions.allApply}">
                                            <th>报名</th>
                                        </c:if>
                                        <c:if test="${permissions.allOrder}">
                                            <th>订单</th>
                                        </c:if>
                                        <c:if test="${permissions.allMoney}">
                                            <th>资金(元)</th>
                                        </c:if>
                                        <c:if test="${permissions.allVisit}">
                                            <th>访问</th>
                                        </c:if>
                                        <c:if test="${permissions.allMember}">
                                            <th>会员</th>
                                        </c:if>
                                        <c:if test="${permissions.allRealMember}">
                                            <th>实名会员</th>
                                        </c:if>
                                    </tr>
                                    </thead>
                                    <tbody>
                                    <tr>
                                        <td>
                                            今日
                                        </td>
                                        <c:if test="${permissions.allApply}">
                                            <td>${map.today.applyNum}</td>
                                        </c:if>
                                        <c:if test="${permissions.allOrder}">
                                            <td>${map.today.orderNum}</td>
                                        </c:if>
                                        <c:if test="${permissions.allMoney}">
                                            <td>
                                                <fmt:formatNumber value="${map.today.money}" pattern="0.00"/>
                                            </td>
                                        </c:if>
                                        <c:if test="${permissions.allVisit}">
                                            <td>${map.today.viewNum}</td>
                                        </c:if>
                                        <c:if test="${permissions.allMember}">
                                            <td>${map.today.memberNum}</td>
                                        </c:if>
                                        <c:if test="${permissions.allRealMember}">
                                            <td>${map.today.realMemberNum}</td>
                                        </c:if>
                                    </tr>
                                    <tr>
                                        <td>
                                            昨日
                                        </td>
                                        <c:if test="${permissions.allApply}">
                                            <td>${map.yesterday.applyNum}</td>
                                        </c:if>
                                        <c:if test="${permissions.allOrder}">
                                            <td>${map.yesterday.orderNum}</td>
                                        </c:if>
                                        <c:if test="${permissions.allMoney}">
                                            <td>
                                                <fmt:formatNumber value="${map.yesterday.money}" pattern="0.00"/>
                                            </td>
                                        </c:if>
                                        <c:if test="${permissions.allVisit}">
                                            <td>${map.yesterday.viewNum}</td>
                                        </c:if>
                                        <c:if test="${permissions.allMember}">
                                            <td>${map.yesterday.memberNum}</td>
                                        </c:if>
                                        <c:if test="${permissions.allRealMember}">
                                            <td>${map.yesterday.realMemberNum}</td>
                                        </c:if>
                                    </tr>
                                    <tr>
                                        <td>
                                            前日
                                        </td>
                                        <c:if test="${permissions.allApply}">
                                            <td>${map.beforeYDay.applyNum}</td>
                                        </c:if>
                                        <c:if test="${permissions.allOrder}">
                                            <td>${map.beforeYDay.orderNum}</td>
                                        </c:if>
                                        <c:if test="${permissions.allMoney}">
                                            <td>
                                                <fmt:formatNumber value="${map.beforeYDay.money}" pattern="0.00"/>
                                            </td>
                                        </c:if>
                                        <c:if test="${permissions.allVisit}">
                                            <td>${map.beforeYDay.viewNum}</td>
                                        </c:if>
                                        <c:if test="${permissions.allMember}">
                                            <td>${map.beforeYDay.memberNum}</td>
                                        </c:if>
                                        <c:if test="${permissions.allRealMember}">
                                            <td>${map.beforeYDay.realMemberNum}</td>
                                        </c:if>
                                    </tr>
                                    <tr>
                                        <td>
                                            本周
                                        </td>
                                        <c:if test="${permissions.allApply}">
                                            <td>${map.week.applyNum}</td>
                                        </c:if>
                                        <c:if test="${permissions.allOrder}">
                                            <td>${map.week.orderNum}</td>
                                        </c:if>
                                        <c:if test="${permissions.allMoney}">
                                            <td>
                                                <fmt:formatNumber value="${map.week.money}" pattern="0.00"/>
                                            </td>
                                        </c:if>
                                        <c:if test="${permissions.allVisit}">
                                            <td>${map.week.viewNum}</td>
                                        </c:if>
                                        <c:if test="${permissions.allMember}">
                                            <td>${map.week.memberNum}</td>
                                        </c:if>
                                        <c:if test="${permissions.allRealMember}">
                                            <td>${map.week.realMemberNum}</td>
                                        </c:if>
                                    </tr>
                                    <tr>
                                        <td>
                                            本月
                                        </td>
                                        <c:if test="${permissions.allApply}">
                                            <td>${map.month.applyNum}</td>
                                        </c:if>
                                        <c:if test="${permissions.allOrder}">
                                            <td>${map.month.orderNum}</td>
                                        </c:if>
                                        <c:if test="${permissions.allMoney}">
                                            <td>
                                                <fmt:formatNumber value="${map.month.money}" pattern="0.00"/>
                                            </td>
                                        </c:if>
                                        <c:if test="${permissions.allVisit}">
                                            <td>${map.month.viewNum}</td>
                                        </c:if>
                                        <c:if test="${permissions.allMember}">
                                            <td>${map.month.memberNum}</td>
                                        </c:if>
                                        <c:if test="${permissions.allRealMember}">
                                            <td>${map.month.realMemberNum}</td>
                                        </c:if>
                                    </tr>
                                    <tr>
                                        <td>
                                            历史
                                        </td>
                                        <c:if test="${permissions.allApply}">
                                            <td>${map.history.applyNum}</td>
                                        </c:if>
                                        <c:if test="${permissions.allOrder}">
                                            <td>${map.history.orderNum}</td>
                                        </c:if>
                                        <c:if test="${permissions.allMoney}">
                                            <td>
                                                <fmt:formatNumber value="${map.history.money}" pattern="0.00"/>
                                            </td>
                                        </c:if>
                                        <c:if test="${permissions.allVisit}">
                                            <td>${map.history.viewNum}</td>
                                        </c:if>
                                        <c:if test="${permissions.allMember}">
                                            <td>${map.history.memberNum}</td>
                                        </c:if>
                                        <c:if test="${permissions.allRealMember}">
                                            <td>${map.history.realMemberNum}</td>
                                        </c:if>
                                    </tr>
                                    </tbody>
                                </table>
                            </div>
                        </div>
                        <div id="page_content" class="page-container"></div>

                        <form class="layui-form"  method="post">
                            <div class="f-search-bar">
                                <div class="search-container">
                                    <ul class="search-form-content">
                                        <li class="form-item">
                                            <label class="search-form-lable">数据</label>
                                            <div class="check-btn-inner">
                                                <c:if test="${permissions.allApply}">
                                                    <a href="javascript:void(0);" onclick="submit($(this),0)" <c:if test="${permissions.showType == 0}">class="active"</c:if>>报名</a>
                                                </c:if>
                                                <c:if test="${permissions.allOrder}">
                                                    <a href="javascript:void(0);" onclick="submit($(this),1)" <c:if test="${permissions.showType == 1}">class="active"</c:if>>订单</a>
                                                </c:if>
                                                <c:if test="${permissions.allMoney}">
                                                    <a href="javascript:void(0);" onclick="submit($(this),2)" <c:if test="${permissions.showType == 2}">class="active"</c:if>>资金</a>
                                                </c:if>
                                                <c:if test="${permissions.allVisit}">
                                                    <a href="javascript:void(0);" onclick="submit($(this),3)" <c:if test="${permissions.showType == 3}">class="active"</c:if>>访问</a>
                                                </c:if>
                                                <c:if test="${permissions.allMember}">
                                                    <a href="javascript:void(0);" onclick="submit($(this),4)" <c:if test="${permissions.showType == 4}">class="active"</c:if>>会员</a>
                                                </c:if>
                                                <input type="hidden" name="type" id="type" value="" />
                                            </div>
                                            <div class="cl"></div>
                                        </li>
                                        <li class="form-item">
                                            <label class="search-form-lable">时间</label>
                                            <div class="layui-input-inline">
                                                <select id="length" name="length" lay-filter="length">
                                                    <option value="7">最近7天</option>
                                                    <option value="15">最近15天</option>
                                                    <option value="30" selected>最近30天</option>
                                                    <option value="0">最近12周</option>
                                                    <option value="-1">最近12月</option>
                                                    <option value="-2">最近24月</option>
                                                </select>
                                            </div>
                                            <div class="cl"></div>
                                        </li>

                                            <%--<li class="form-item">
                                                <label class="search-form-lable">时间</label>
                                                <div class="check-btn-inner">
                                                    <a href="javascript:void(0);" onclick="submit($(this),7)" >最近七天</a>
                                                    <a href="javascript:void(0);" onclick="submit($(this),15)" >最近半个月</a>
                                                    <a href="javascript:void(0);" onclick="submit($(this),30)" class="active" >最近一个月</a>
                                                    <input type="hidden" name="length" id="length" value="" />
                                                </div>
                                                <div class="cl"></div>
                                            </li>--%>
                                    </ul>
                                </div>
                            </div>
                        </form>
                    </div>
                    <div class="content mt15" id="charts" style="height:400px;"></div>
                </div>
                <%@include file="../../include/footer.jsp"%>
            </section>
        </c:if>
        <c:if test="${permissions.noPermission}">
            <section>
                <div style="text-align: center; line-height: 400px; font-size: 30px; font-weight: bold; color: #617775">
                    你没有该页面的数据访问权限, 请联系管理员
                </div>
            </section>
        </c:if>
    </div>

<script type="text/javascript" src="${ctx}/static/echarts-3.0/echarts.min.js"></script>
<script type="text/javascript" src="${ctx}/static/echarts-3.0/base_config.js"></script>
<script type="text/javascript">
    $(function () {
        layui.use(['form', 'laydate'], function () {
            form = layui.form, laydate = layui.laydate;
            form.on('select(length)', function (data) {
                var type = $("#type").val();
                var length = data.value;
                getData(type, length);
            });
        });
    });

    function getData(type, length) {
        var memberId = '${memberId}';
        $.get('${ctx}/merchant/analyze/adminchart.do',
                {type : type, length: length, memberId :memberId},
                function (res) {
                    var charts = echarts.init(document.getElementById('charts'));

                    var option = {
                        title : {
                            text:'数据趋势图'
                        },
                        xAxis: [
                            {
                                data: res.data.dateList
                            }
                        ],
                        series: [
                            {
                                data: res.data.dataList
                            }
                        ]
                    };
                    option = getEchartBaseLineOpt(option);
                    charts.setOption(option);
                })
    }

    getData(${permissions.showType}, '');

    function submit(obj, value) {
        $(obj).parent(".check-btn-inner").find("a").removeClass("active");
        $(obj).addClass("active");
        $(obj).parent(".check-btn-inner").find("[type=hidden]").val(value);
        var type = $("#type").val();
        var length = $("#length").val();
        getData(type, length);
    }

    <shiro:hasPermission name="admin:home:allApply-click">
    $('#allApply-num').on('click', function () {
        window.location.href = "${ctx}/activity/memberAct/applyList.do";
    });
    </shiro:hasPermission>

    <shiro:hasPermission name="admin:home:allOrder-click">
    $('#order-num').on('click', function () {
        window.location.href="${ctx}/order/order/orderList.do";
    });
    </shiro:hasPermission>

    <shiro:hasPermission name="admin:home:allMember-click">
    $('#member-num').on('click', function () {
        window.location.href = "${ctx}/system/member/memberList.do";
    });
    </shiro:hasPermission>

    $('#unauditedMember-num').on('click', function () {
        window.location.href = "${ctx}/system/member/memberList.do?userStatus=0";
    });
</script>
</body>
</html>
